package com.tianji.remark.controller;


import com.tianji.remark.domain.dto.LikeRecordFormDTO;
import com.tianji.remark.service.ILikedRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Set;

/**
 * <p>
 * 点赞记录表 前端控制器
 * </p>
 *
 * @author yangyu
 * @since 2023-07-28
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/likes")
@Api(tags = "点赞业务相关接口")
public class LikedRecordController {

    private final ILikedRecordService likedRecordService;

    /**
     * 点赞或取消
     * @param likeRecordDTO 点赞记录表单实体
     */
    @PostMapping
    @ApiOperation("点赞或取消")
    public void addLikeRecord(@RequestBody LikeRecordFormDTO likeRecordDTO){
        likedRecordService.addLikeRecord(likeRecordDTO);
    }


    /**
     * 批量查询点赞状态
     * @param bizIds 业务id集合
     * @return 已点赞的业务id集合
     */
    @GetMapping("/list")
    @ApiOperation("查询指定业务id的点赞状态")
    public Set<Long> isBizLiked(@RequestParam("bizIds") List<Long> bizIds){
       return likedRecordService.isBizLiked(bizIds);
    }

    //TODO 点赞功能改进

}
